#pragma once

#include <atomic>

namespace cq {
   /// As suggested in: http://stackoverflow.com/questions/13193484/how-to-declare-a-vector-of-atomic-in-c
   struct atomicbool {
     private:
      std::atomic<bool> value_;

     public:
      atomicbool() :
          value_{false} {}
      atomicbool(bool value) :
          value_{value} {}
      atomicbool(const std::atomic<bool>& value) :
          value_{value.load(std::memory_order_acquire)} {}
      atomicbool(const atomicbool& other) :
          value_{other.value_.load(std::memory_order_acquire)} {}

      atomicbool& operator=(const atomicbool& other) {
         value_.store(other.value_.load(std::memory_order_acquire), std::memory_order_release);
         return *this;
      }

      atomicbool& operator=(const bool other) {
         value_.store(other, std::memory_order_release);
         return *this;
      }

      bool operator==(const atomicbool& rhs) const {
         return (value_.load(std::memory_order_acquire) == rhs.value_.load(std::memory_order_acquire));
      }

      bool value() { return value_.load(std::memory_order_acquire); }
      std::atomic<bool>& get() { return value_; }
   };
}  // namespace cq
   // explicit whitespace/EOF for VS15
